package 斗地主;

import java.util.*;

public class PokerGame {
    static HashMap<Integer, String> hm = new HashMap<>();
    static ArrayList<Integer> list = new ArrayList<>();
    static {
        String[] str1 = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        String[] str2 = {"♠", "♥", "♣", "♦"};
        int flag = 1;
        for (String i : str1){
            for (String j : str2){
                list.add(flag);
                hm.put(flag, j + i);
                flag++;
            }
        }
        list.add(flag);
        hm.put(flag, "小王");
        flag++;
        list.add(flag);
        hm.put(flag, "大王");
    }
    public PokerGame() {
        Collections.shuffle(list);
        TreeSet<Integer> lord = new TreeSet<>();
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();
        for (int i = 0; i < list.size(); i++) {
            if (i<3){
                lord.add(list.get(i));
            }
            else if (i%3 == 0){
                player1.add(list.get(i));
            }
            else if (i%3 == 1){
                player2.add(list.get(i));
            }
            else {
                player3.add(list.get(i));
            }
        }
        fenpai("底牌", lord);
        fenpai("高代起", player1);
        fenpai("李东键", player2);
        fenpai("韩瑞杰", player3);
    }
    public void fenpai(String name, TreeSet<Integer> s){
        Iterator<Integer> iterator = s.iterator();
        System.out.print(name+": ");
        while (iterator.hasNext()){
            int flag = iterator.next();
            System.out.print(hm.get(flag) + " ");
        }
        System.out.println();
    }
}
